using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace DataLayerTest.Models.Mapping
{
    public class OutdoorExerciseSocialMap : EntityTypeConfiguration<OutdoorExerciseSocial>
    {
        public OutdoorExerciseSocialMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.Id)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.Name)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.Description)
                .HasMaxLength(100);

            this.Property(t => t.ImageUrl)
                .HasMaxLength(50);

            // Table & Column Mappings
            this.ToTable("OutdoorExerciseSocial");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.IdPlayerGroup).HasColumnName("IdPlayerGroup");
            this.Property(t => t.Name).HasColumnName("Name");
            this.Property(t => t.Type).HasColumnName("Type");
            this.Property(t => t.Description).HasColumnName("Description");
            this.Property(t => t.ImageUrl).HasColumnName("ImageUrl");

            // Relationships
            this.HasRequired(t => t.OutdoorExercise)
                .WithOptional(t => t.OutdoorExerciseSocial);
            this.HasRequired(t => t.PlayerGroup)
                .WithMany(t => t.OutdoorExerciseSocials)
                .HasForeignKey(d => d.IdPlayerGroup);

        }
    }
}
